// const baseUrl = 'https://pyw.peiyiyiliao.com/prod-api'
const baseUrl = "http://192.168.1.123:9274"
const request = (url, data, method,type) => {
	let token = uni.getStorageSync('token')
	if(!token && url != '/api/applet/AuthorizedLogin'){
		return
	}
	return new Promise((resolve, reject) => {
		uni.request({
			url: baseUrl + url,
			data,
			header: {
				'Authorization': 'abcdefghijklmnopqrstuvwxyz',
				'token': token,
				'Content-Type': type ? 'application/json' : 'application/x-www-form-urlencoded;charset=UTF-8'
				// 'Content-Type': 'application/json'
			},
			method,
			success: res => {
				if(res.data.code != 200){
					uni.showToast({
						title: res.data.msg,
						icon: 'none',
						duration: 2000
					})
				}
				resolve(res)
			},
			fail: err => {
				reject(err)
			}
		})
	})
}
export default request